package cn.zglbk.utils;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;

/**
 * @author 猪哥亮
 * @email 1030681978@qq.com
 * @date 2020/5/5 15:22
 * 描述：
 */
public final class SaltUtils {
    private SaltUtils(){}
    public static String salt(String pwd,String salt){
        String[] ns = StringUtils.split(salt,"_");
        int pwdLength = pwd.length();
        String sub = pwd.substring(0, pwdLength / 2);
        String npwd = ns[0] + sub;
        npwd += ns[1];
        npwd += pwd.substring(pwdLength / 2,pwdLength);
        npwd += ns[2];
        return Md5Utils.wxMd5(npwd);
    }
    public static String salt(){
        String salt1 = RandomStringUtils.randomAlphabetic(3);
        String salt2 = RandomStringUtils.randomNumeric(3);
        String salt3 = RandomStringUtils.randomAlphabetic(3);
        return salt1 + "_" + salt2 + "_" + salt3;
    }

    public static void main(String[] args) {
        StringBuilder sb = new StringBuilder("1234156789000");
        for (int i = 0; i < sb.length(); i++) {
            if(i % 3 == 1){
                sb.insert(i,",");
            }
        }
        System.out.println(sb.toString());
    }
}
